import React, { Component } from 'react';
import {Route, Redirect} from 'react-router-dom';
import util from './common/until'
class PrivateRoute extends Component {
    state = {  }
    render() { 
        let {component:Component,user,...rest} = this.props;
        console.log(this.props)
        return (
            <div>
                <Route {...rest} render={(props) => util.get('user').username ? <Component {...props}/> : <Redirect to={{pathname: "/login"}}/>
        }/>
            </div>
        );
    }
}
export default PrivateRoute;